home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / gfx / x11 / x3270_3_2_16.lha / unix_files / Cme.c < prev    next >
C/C++ Source or Header  |  2008-10-18  |  8KB  |  246 lines

  1. /* (from) $XConsortium: Sme.c,v 1.9 91/02/17 16:44:14 rws Exp $ */
  2.  
  3. /*
  4.  * Modifications Copyright 1995, 1999, 2000 by Paul Mattes.
  5.  *  Permission to use, copy, modify, and distribute this software and its
  6.  *  documentation for any purpose and without fee is hereby granted,
  7.  *  provided that the above copyright notice appear in all copies and that
  8.  *  both that copyright notice and this permission notice appear in
  9.  *  supporting documentation.
  10.  *
  11.  * Copyright 1989 Massachusetts Institute of Technology
  12.  *
  13.  * Permission to use, copy, modify, distribute, and sell this software and its
  14.  * documentation for any purpose is hereby granted without fee, provided that
  15.  * the above copyright notice appear in all copies and that both that
  16.  * copyright notice and this permission notice appear in supporting
  17.  * documentation, and that the name of M.I.T. not be used in advertising or
  18.  * publicity pertaining to distribution of the software without specific,
  19.  * written prior permission.  M.I.T. makes no representations about the
  20.  * suitability of this software for any purpose.  It is provided "as is"
  21.  * without express or implied warranty.
  22.  *
  23.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  24.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  25.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  26.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  27.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  28.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29.  */
  30.  
  31. /*
  32.  * Cme.c - Source code for the generic menu entry
  33.  * (from) Sme.c - Source code for the generic menu entry
  34.  *
  35.  * Date:    September 26, 1989
  36.  *
  37.  * By:      Chris D. Peterson
  38.  *          MIT X Consortium 
  39.  *          kit@expo.lcs.mit.edu
  40.  */
  41.  
  42. #include "globals.h"
  43. #if defined(X3270_MENUS) /*[*/
  44.  
  45. #include <stdio.h>
  46. #include <X11/IntrinsicP.h>
  47. #include <X11/StringDefs.h>
  48.  
  49. #include <X11/Xaw/XawInit.h>
  50. #include "CmeP.h"
  51. #include <X11/Xaw/Cardinals.h>
  52.  
  53. #define offset(field) XtOffsetOf(CmeRec, cme.field)
  54. static XtResource resources[] = {
  55.   {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
  56.      offset(callbacks), XtRCallback, (XtPointer)NULL},
  57. };   
  58. #undef offset
  59.  
  60. /*
  61.  * Semi Public function definitions. 
  62.  */
  63.  
  64. static void Highlight(Widget);
  65. static void Unhighlight(Widget);
  66. static void Notify(Widget);
  67. static void ClassPartInitialize(WidgetClass);
  68. static void Initialize(Widget, Widget, ArgList, Cardinal *);
  69. static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
  70.     XtWidgetGeometry *);
  71.  
  72. #define SUPERCLASS (&rectObjClassRec)
  73.  
  74. CmeClassRec cmeClassRec = {
  75.   {
  76.     /* superclass         */    (WidgetClass) SUPERCLASS,
  77.     /* class_name         */    "Cme",
  78.     /* size               */    sizeof(CmeRec),
  79.     /* class_initialize   */    XawInitializeWidgetSet,
  80.     /* class_part_initialize*/    ClassPartInitialize,
  81.     /* Class init'ed      */    FALSE,
  82.     /* initialize         */    Initialize,
  83.     /* initialize_hook    */    NULL,
  84.     /* realize            */    NULL,
  85.     /* actions            */    NULL,
  86.     /* num_actions        */    ZERO,
  87.     /* resources          */    resources,
  88.     /* resource_count     */    XtNumber(resources),
  89.     /* xrm_class          */    NULLQUARK,
  90.     /* compress_motion    */    FALSE, 
  91.     /* compress_exposure  */    FALSE,
  92.     /* compress_enterleave*/     FALSE,
  93.     /* visible_interest   */    FALSE,
  94.     /* destroy            */    NULL,
  95.     /* resize             */    NULL,
  96.     /* expose             */    NULL,
  97.     /* set_values         */    NULL,
  98.     /* set_values_hook    */    NULL,
  99.     /* set_values_almost  */    XtInheritSetValuesAlmost,  
  100.     /* get_values_hook    */    NULL,            
  101.     /* accept_focus       */    NULL,
  102.     /* intrinsics version */    XtVersion,
  103.     /* callback offsets   */    NULL,
  104.     /* tm_table          */    NULL,
  105.     /* query_geometry      */    QueryGeometry,
  106.     /* display_accelerator*/    NULL,
  107.     /* extension      */    NULL
  108.   },{
  109.     /* Complex Menu Entry Fields */
  110.       
  111.     /* highlight */             Highlight,
  112.     /* unhighlight */           Unhighlight,
  113.     /* notify */        Notify,        
  114.     /* extension */             NULL                
  115.   }
  116. };
  117.  
  118. WidgetClass cmeObjectClass = (WidgetClass) &cmeClassRec;
  119.  
  120. /************************************************************
  121.  *
  122.  * Semi-Public Functions.
  123.  *
  124.  ************************************************************/
  125.  
  126. /*    Function Name: ClassPartInitialize
  127.  *    Description: handles inheritance of class functions.
  128.  *    Arguments: class - the widget classs of this widget.
  129.  *    Returns: none.
  130.  */
  131.  
  132. static void
  133. ClassPartInitialize(WidgetClass class)
  134. {
  135.     CmeObjectClass m_ent, superC;
  136.  
  137.     m_ent = (CmeObjectClass) class;
  138.     superC = (CmeObjectClass) m_ent->rect_class.superclass;
  139.  
  140. /* 
  141.  * We don't need to check for null super since we'll get to TextSink
  142.  * eventually.
  143.  */
  144.  
  145.     if (m_ent->cme_class.highlight == XtInheritHighlight) 
  146.     m_ent->cme_class.highlight = superC->cme_class.highlight;
  147.  
  148.     if (m_ent->cme_class.unhighlight == XtInheritUnhighlight)
  149.     m_ent->cme_class.unhighlight = superC->cme_class.unhighlight;
  150.  
  151.     if (m_ent->cme_class.notify == XtInheritNotify) 
  152.     m_ent->cme_class.notify = superC->cme_class.notify;
  153. }
  154.  
  155. /*      Function Name: Initialize
  156.  *      Description: Initializes the complex menu widget
  157.  *      Arguments: request - the widget requested by the argument list.
  158.  *                 new     - the new widget with both resource and non
  159.  *                           resource values.
  160.  *      Returns: none.
  161.  * 
  162.  * MENU ENTRIES CANNOT HAVE BORDERS.
  163.  */
  164.  
  165. static void
  166. Initialize(Widget request unused, Widget new, ArgList args unused,
  167.     Cardinal *num_args unused)
  168. {
  169.     CmeObject entry = (CmeObject) new;
  170.  
  171.     entry->rectangle.border_width = 0;
  172. }
  173.  
  174. /*    Function Name: Highlight
  175.  *    Description: The default highlight proceedure for menu entries.
  176.  *    Arguments: w - the menu entry.
  177.  *    Returns: none.
  178.  */
  179.  
  180. static void
  181. Highlight(Widget w unused)
  182. {
  183. /* This space intentionally left blank. */
  184. }
  185.  
  186. /*    Function Name: Unhighlight
  187.  *    Description: The default unhighlight proceedure for menu entries.
  188.  *    Arguments: w - the menu entry.
  189.  *    Returns: none.
  190.  */
  191.  
  192. static void
  193. Unhighlight(Widget w unused)
  194. {
  195. /* This space intentionally left blank. */
  196. }
  197.  
  198. /*    Function Name: Notify
  199.  *    Description: calls the callback proceedures for this entry.
  200.  *    Arguments: w - the menu entry.
  201.  *    Returns: none.
  202.  */
  203.  
  204. static void
  205. Notify(Widget w)
  206. {
  207.     XtCallCallbacks(w, XtNcallback, NULL);
  208. }
  209.  
  210. /*    Function Name: QueryGeometry.
  211.  *    Description: Returns the preferred geometry for this widget.
  212.  *    Arguments: w - the menu entry object.
  213.  *                 itended, return - the intended and return geometry info.
  214.  *    Returns: A Geometry Result.
  215.  *
  216.  * See the Intrinsics manual for details on what this function is for.
  217.  * 
  218.  * I just return the height and a width of 1.
  219.  */
  220.  
  221. static XtGeometryResult
  222. QueryGeometry(Widget w, XtWidgetGeometry *intended,
  223.     XtWidgetGeometry *return_val)
  224. {
  225.     CmeObject entry = (CmeObject) w;
  226.     Dimension width;
  227.     XtGeometryResult ret_val = XtGeometryYes;
  228.     XtGeometryMask mode = intended->request_mode;
  229.  
  230.     width = 1;            /* we can be really small. */
  231.  
  232.     if ( ((mode & CWWidth) && (intended->width != width)) ||
  233.      !(mode & CWWidth) ) {
  234.     return_val->request_mode |= CWWidth;
  235.     return_val->width = width;
  236.     mode = return_val->request_mode;
  237.     
  238.     if ( (mode & CWWidth) && (width == entry->rectangle.width) )
  239.         return(XtGeometryNo);
  240.     return(XtGeometryAlmost);
  241.     }
  242.     return(ret_val);
  243. }
  244.  
  245. #endif /*]*/
  246.